package com.hwua.view;

import com.hwua.domain.Car;
import com.hwua.service.CarService;
import com.hwua.serviceimpl.CarServiceImpl;
import com.hwua.util.InputTools;

import java.util.List;

/**
 * 通过汽车编号查找指定汽车的界面
 * @author admin
 */
public class FindCarByCarIdView extends AbstractView{
    private int num2;
    public FindCarByCarIdView(int num2){
        this.num2=num2;
    }
    @Override
    public AbstractView showView() {
        String sign = "汽车id";
        String rentStatus=null;
        String putAwayStatus=null;
        CarService cs = new CarServiceImpl();
        List<Car> carList = cs.findCarById(num2,sign);
        System.out.println("==============================================<<指定汽车编号的汽车>>>==============================================");
        System.out.println("编号\t汽车名称\t\t备注\t\t\t品牌\t\t类型\t\t颜色\t\t日租金\t\t是否可租\t\t是否上架");
        for (Car car : carList) {
            if(car.getRentStatus()==0){
                rentStatus="可租";
            }else{
                rentStatus="不可租";
            }
            if(car.getPutAwayStatus()==0){
                putAwayStatus="上架";
            }else{
                putAwayStatus="下架";
            }
            System.out.println(car.getCarId()+"\t\t"+car.getCarName()+"\t\t\t"+car.getCarRemark()+"\t\t"+ car.getBrand()
                    +"\t\t"+car.getType()+"\t\t"+car.getColor()+"\t\t"+car.getDailyRent()+"\t\t"+rentStatus+"\t\t\t"+putAwayStatus);

        }
        System.out.println("===============================================================================================");
        System.out.println();
        System.out.println("输入0：           退出");
        System.out.println("输入1：           查看全部汽车");
        System.out.println("输入2：           添加汽车");
        System.out.println("输入3：           修改当前汽车信息");
        int choose = InputTools.checkIntInput(0, 3);
        switch (choose){
            case 0:
                nextView=null;
                break;
            case 1:
                nextView = new AdminView();
                break;
            case 2:
                nextView = new AddCarView();
                break;
            case 3:
                nextView = new AlterCarByCarIdView(num2);
                break;
            default:break;
        }
        return nextView;
    }
}
